#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<string>
#include<iostream>

using namespace std;

void testset()
{
	set<int> set1;
	set1.insert(1);

	string str = "abcdef";
	set<char> set2(str.begin(), str.end());

	auto set2cur = set2.begin();
	for (auto e : set2)
	{
		cout << e << endl;
	}

	cout << "set2->empty" << set2.empty() << endl;
	cout << "set2->size" << set2.size() << endl;
	cout << "set2->cout" << set2.count(1) << endl;
}

void testmultiset()
{
	string str("asdffjghfgwtertytyiyrsxcvbfa");
	multiset<char> metiset(str.begin(), str.end());

	for (auto e : metiset)
	{
		cout << e << endl;
	}
	 

	cout << "multiset->count" << metiset.count('f') << endl;
	cout << "multiset->size" << metiset.size() << endl;

}

void testmap()
{
	map<int, string> map1;
	map1.insert(make_pair(1, "a"));
	map1.insert(make_pair(2, "b"));
	map1.insert(make_pair(3, "c"));
	map1.insert(make_pair(4, "d"));
	map1.insert(make_pair(5, "e"));
	map1.insert(make_pair(6, "f"));
	map1.insert(make_pair(7, "g"));
	map1.insert(pair<int, string>(8, "h"));
	map1.insert(pair<int, string>(3, "c"));
	auto cur = map1.begin();
	while (cur!=map1.end())
	{
		cout << cur->first << "->" << cur->second << endl;
		++cur;
	}

	map1.erase(4);

	for (auto e : map1)
	{
		cout << e.first << e.second << endl;
	}

	cout << "map1->empty" << map1.empty() << endl;
	cout << "map1->size" << map1.size() << endl;
	cout << "map1->cout" << map1.count(1) << endl;


	string str1 = "abcdefgh";
	map<int, char> map2;
	for (int i = 0; i < str1.size(); i++)
	{
		map2.insert(make_pair(i, str1[i]));
	}
	for (auto e : map2)
	{
		cout << e.first << e.second << endl;
	}

	map<int, char>::iterator iter = map2.find(3);
	cout << iter->first <<iter->second<< endl;

	map2[3] = 's';
	cout << iter->first << iter->second << endl;
}

void testmultimap()
{
	multimap<int, char> mutimap;
	string str("zxcvvjgfsdsaqwerty");
	for (int i = 0; i < str.size(); i++)
	{
		mutimap.insert(make_pair(i,str[i]));
	}

	auto cur = mutimap.begin();
	 
	while (cur != mutimap.end())
	{
		cout << cur->first << cur->second << endl;
		++cur;
	}
	 

}

int main()
{
	//testmap();
	//testset();
	//testmultiset();
	testmultimap();
	return 0;
}
